home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2651 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  54 lines

  1. Path: news.ov.com!news
  2. From: glenn@ov.com (Fletcher.Glenn@ov.com)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: directory functions ...
  5. Date: 22 Jan 1996 22:44:47 GMT
  6. Organization: OpenVision
  7. Message-ID: <4e140v$e80@spanky.pls.ov.com>
  8. References: <30FF91CE.3F54@ehvvs5.nwg.dec.com>
  9. Reply-To: glenn@ov.com
  10. NNTP-Posting-Host: foghorn.pls.ov.com
  11.  
  12. In article 3F54@ehvvs5.nwg.dec.com, Hussein Salem <salem@ehvvs5.nwg.dec.com> writes:
  13. >Hi,
  14. >
  15. >I'm trying to make a small program in C handling a directory. open it and print it's content
  16. >:
  17. >
  18. >
  19. >The problem is it can't read it ! Why ? I 've set the mode to a+rwx to that direstory !
  20. >
  21. >These are the code and if you know what's the problem please tell me why ?
  22. >
  23. >-----------------
  24. >
  25. >#include <stdio.h>
  26. >#include <dirent.h>
  27. >#include <sys/types.h>
  28. >#define MYMAX   14
  29. >
  30. >typedef struct {
  31. >        long ino;
  32. >        char name[MYMAX+1];
  33. >} Dirent;
  34. >
  35. >main(int argc,char **argv){
  36. >char name[MYMAX];
  37. >DIR     *dfd;
  38. >char *dir;
  39. >Dirent  *dp;
  40. >
  41. >dir = "/usr/users/salem/test";
  42. >
  43. >if ((dfd = opendir(dir) == NULL)) {
  44.  
  45. You really want to say:
  46.  
  47. if ((dfd = opendir(dir)) == NULL)  {
  48.  
  49. [irrelevant remainder snipped]
  50.  
  51.             Fletcher.Glenn@ov.com
  52.  
  53.  
  54.